{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "a=1\n",
    "b=a \n",
    "a = a +1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n"
     ]
    }
   ],
   "source": [
    "print(a==b)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4, 4]\n",
      "[1, 2, 3, 4, 4]\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "l1 = [1,2,3,4]\n",
    "l2 = l1\n",
    "l1.append(4)\n",
    "print(l1)\n",
    "print(l2)\n",
    "print(l1 is l2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Python 中参数的传递既不是值传递，也不是引用传递，而是赋值传递，或者是叫对象的引用传递。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "l1 = [1, 2, 3]\n",
    "l2 = [1, 2, 3]\n",
    "l3 = l2\n",
    "print(l1 is l2)\n",
    "print(l2 is l3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'a': 10, 'b': 20}\n"
     ]
    }
   ],
   "source": [
    "def func(d):\n",
    "    d['a'] = 10\n",
    "    d['b'] = 20\n",
    "\n",
    "d = {'a': 1, 'b': 2}\n",
    "func(d)\n",
    "print(d)    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "20\n"
     ]
    }
   ],
   "source": [
    "def func(a,b):\n",
    "    a=2\n",
    "    b=3\n",
    "a,b = 10,20\n",
    "func(a,b)\n",
    "print(a)\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2, 2, 3, 4]\n",
      "[3, 6, 7, 8]\n"
     ]
    }
   ],
   "source": [
    "def func(a,b):\n",
    "    a[0]=2\n",
    "    b[0]=3\n",
    "\n",
    "a = [1,2,3,4]\n",
    "b = [5,6,7,8]\n",
    "func(a,b)\n",
    "print(a)\n",
    "print(b)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
